#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/types.h>
#include <linux/miscdevice.h>
MODULE_LICENSE("GPL");
char *ringbuf = "eeeee";

ssize_t xread(struct file *fp,char __user *buf,size_t len ,loff_t *off)
{
	strncpy(buf ,ringbuf,len);
	return len;
}

ssize_t xwrite(struct file *fp,const char __user *buf,size_t len ,loff_t *off)
{
			strncpy(ringbuf,buf,len);
	return len;
}

int xopen(struct inode *no,struct file*fp)
{
	printk("xopen\n");
	return 0;
}
int xrelease(struct inode *no,struct file *fp)
{
	printk("xrelease\n");
	return 0;
}

struct file_operations xfops = {
	.open = xopen,
	.read = xread,
	.write = xwrite,
	.release = xrelease,
};
struct miscdevice devs = {
      .minor = 78,
      .name = "xdnmisc",
     .fops = &xfops,
 };

int chadev_init(void)
{
		misc_register(&devs);
		return 0;
}


void chadev_exit(void)
{
		printk("bay\n");
		misc_deregister(&devs);
}

module_init(chadev_init);
module_exit(chadev_exit);
